package com.automannn.websocketmqtt.websocketNodeB.amqp.config;

import com.automannn.websoketmqtt.common.message.WsMessageQueueProperties;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author chenkh
 * @time 2020/10/13 11:16
 */
@Configuration
public class WsNodeATopicRabbitConfig {

    /**
     * 队列配置
     */
    @Bean
    public Queue theQueue(){
        return new Queue(WsMessageQueueProperties.TOPIC_FLAG+".com.automannn.websocketmqtt.rocketmq.nodeB");
    }

    /**
     * 交换机配置
     */
    @Bean
    public TopicExchange automannnTopicExchange(){
        return new TopicExchange(WsMessageQueueProperties.WS_EXCHANGE);
    }

    /**
     * 绑定 严格路由键
     */
    @Bean
    public Binding bindingTopicExchangeMessage1(){
        return BindingBuilder.bind(theQueue()).to(automannnTopicExchange()).with(WsMessageQueueProperties.TOPIC_FLAG+".#");
    }
}
